﻿Public Class CompilerInfo
#Region "Properties"
    'Public Properties
    Public Property StartBlock As Char = "{"c
    Public Property EndBlock As Char = "}"c
    Public Property Collection As Char = "&"c
    Public Property VariableName As Char = "."c
    Public Property VariableValue As Char = "="c
    Public Property ObjectId As Char = "#"c
    Public Property Null As Char = "!"c
    Public Property Format As Boolean = True
    Public Property PsudoTypeNameProvider As PsudoTypeNameProviderHandler = Nothing
    Public Property RealTypeProvider As RealTypeProviderHandler = Nothing
    'Friend Properties
    Friend Property Tabs As String = ""
    Friend Property CacheObjects As New List(Of Object)
    Friend Property TypeProviders As New Dictionary(Of Type, TypeProvider)
#End Region
#Region "Methods"
    'Cache
    Public Sub AddCache(Obj As Object)
        If Not CacheObjects.Contains(Obj) Then
            CacheObjects.Add(Obj)
        End If
    End Sub
    Public Sub AddCache(Obj() As Object)
        For Each o As Object In Obj
            AddCache(o)
        Next
    End Sub
    Public Sub RemoveCache(Obj As Object)
        If CacheObjects.Contains(Obj) Then CacheObjects.Remove(Obj)
    End Sub
    Public Sub RemoveCache(Obj() As Object)
        For Each o As Object In Obj
            RemoveCache(o)
        Next
    End Sub
    Public Function CacheID(Obj As Object) As Integer
        Return CacheObjects.IndexOf(Obj)
    End Function
    Public Function GetCache(ID As Integer) As Object
        Return CacheObjects(ID)
    End Function
    Public Function CacheContains(Obj As Object) As Boolean
        Return CacheObjects.Contains(Obj)
    End Function
    Public Sub ClearCache()
        CacheObjects.Clear()
    End Sub
    'Type Provides
    Public Sub AddProvider(Provd As TypeProvider)
        For Each t As Type In Provd.Types
            TypeProviders.Add(t, Provd)
        Next
    End Sub
    Public Sub AddProviders(Provd() As TypeProvider)
        For Each op As TypeProvider In Provd
            AddProvider(op)
        Next
    End Sub
    Public Sub RemoveProvider(P As TypeProvider)
        For Each t As Type In P.Types
            TypeProviders.Remove(t)
        Next
    End Sub
    Public Sub RemoveProviders(P() As TypeProvider)
        For Each op As TypeProvider In P
            RemoveProvider(op)
        Next
    End Sub
    Public Function FindProvider(T As Type) As TypeProvider
        For Each Tx As Type In TypeProviders.Keys
            If T Is Tx Or T.IsSubclassOf(Tx) Or T.GetInterfaces.Contains(Tx) Then
                Return TypeProviders(Tx)
            End If
        Next
        Return Nothing
    End Function
    'Others
    Public Function TabCount() As Integer
        Return Tabs.Length
    End Function
#End Region
#Region "Types"
    Public Delegate Function PsudoTypeNameProviderHandler(Type As Type) As String
    Public Delegate Function RealTypeProviderHandler(PsudoName As String) As Type
#End Region
End Class